<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ attribute name="pageURL" required="true" rtexprvalue="true" description="pageURL"%>
<%@ attribute name="pageAttrKey" required="true" rtexprvalue="true" description="pageAttrKey"%>
<c:set var="pageURL" value="${pageURL}"/>
<% 
  String separator = pageURL.indexOf("?") > -1 ? "&" : "?";
  jspContext.setAttribute("pageResult", request.getAttribute(pageAttrKey));
  jspContext.setAttribute("pageURL", pageURL);
  jspContext.setAttribute("separator", separator);
%>
PageCount: ${pageResult.pageCount}&nbsp; PageNo: ${pageResult.pageNo}&nbsp;&nbsp;  
<c:if test="${pageResult.pageNo <= 1}">
  First Page&nbsp;
</c:if>
<c:if test="${pageResult.pageNo > 1}">
  <a href="<c:url value="${pageURL}"/>${separator}pageNo=1">First Page</a>&nbsp;
</c:if>
<c:if test="${pageResult.hasPrevious}">
  <a href="<c:url value="${pageURL}"/>${separator}pageNo=${pageResult.pageNo-1}">Previous Page</a>&nbsp;
</c:if>
<c:if test="${!pageResult.hasPrevious}">
  Previous Page&nbsp;
</c:if>
<c:if test="${pageResult.hasNext}">
  <a href="<c:url value="${pageURL}"/>${separator}pageNo=${pageResult.pageNo+1}">Next Page</a>&nbsp;
</c:if>
<c:if test="${!pageResult.hasNext}">
  Next Page&nbsp;
</c:if>
<c:if test="${pageResult.pageNo >= pageResult.pageCount}">
  Last Page
</c:if>
<c:if test="${pageResult.pageNo < pageResult.pageCount}">
  <a href="<c:url value="${pageURL}"/>${separator}pageNo=${pageResult.pageCount}">Last page</a>
</c:if>